/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DBHandling;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author NguyenPhuThien
 */
public class ReturnRecieptHandling {

    private DBUtil objDB;
    private Connection conn;

    public ReturnRecieptHandling() {
        this.objDB = new DBUtil();
        this.conn = objDB.connect();
    }

    public boolean insertReciept(String billID, String itemID, int quantity, String date) throws Exception {
        try {
            String sql = "{call sp_addRecieptDetail" + "(?, ?, ?, ?)}";
            Object[] objects = {billID, itemID, quantity, date};
            return objDB.executeProcedureUpdate(sql, objects);
        } catch (Exception ex) {
            throw ex;
        }
    }
    public int getTotalItemReturned(String from, String to) throws Exception{
        try {
            String sql = "select count(*) from RecieptDetails where returnDate >= '" + from + "' AND returnDate <= '" + to + "'";
            ResultSet rs = objDB.executeSQL(sql);
            rs.next();
            return rs.getInt(1);
        } catch (SQLException ex) {
            throw ex;
        }
        
    }
}
